
uniform vec3 vp;
uniform vec3 scale;
uniform mat4 pMatrix;


attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec3 a_offset;

varying vec3 vTexCoord;
varying vec3 vNormal;
varying vec3 vViewVec;

void main(void)
{

   vec4 pos = pMatrix * vec4(a_position, 1.0) ;   
  
   gl_Position =  pos;

   vTexCoord   = a_position*scale/scale-a_offset;///scale;//pos.xyz * scale ;

	pos.xyz += vp.xyz - a_offset;
	
	//pos.xy += a_position.xy;
	
	pos.z = normalize(pos.z);
   vViewVec    = pos.xyz;
   vNormal     = a_normal;
}